<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<title>后台登录</title>
	<link rel="shortcut icon" href="__admin__/admin.png" />
	<link href="__admin__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__admin__/css/nifty.min.css" rel="stylesheet">
	<script src="__admin__/js/jquery-2.1.1.js"></script>
</head>
<body>
	<div id="container" class="cls-container">
		<div id="bg-overlay" class="bg-img" style="background-image: url(__admin__/img/bg-img-7.jpg)"></div>
		<div class="cls-content">
		    <div class="cls-content-sm panel" style="margin-top: 7%">
		        <div class="panel-body">
		            <form id="form" method="post">
						<div class="panel-body text-center">
							<img alt="Profile Picture" class="img-lg img-circle mar-btm" src="__admin__/img/5.png">
							<p class="text-lg text-semibold mar-no text-main">后台登录</p>
							<p class="text-muted"></p>
							<p class="text-sm">请勿将您的账号密码告诉他人！ </p>
						</div>
		                <div class="form-group">
		                    <input type="text" class="form-control" name="username" placeholder="管理员名" autofocus id="username">
		                </div>
		                <div class="form-group">
		                    <input type="password" class="form-control" name="password" placeholder="管理员密码" id="password">
		                </div>
						<div class="form-group">
		                    <input type="captcha" class="form-control" name="captcha" placeholder="验证码" style="width: 50%; float: left" id="captcha"><img src="{:captcha_src()}" alt="captcha" style="cursor: pointer" onclick="this.src=this.src+'?'+Math.random()" id="captcha_img"/>
		                </div>
		                <button class="btn btn-primary btn-block" id="sub" type="button">登录账号</button>
						<br/>
						<span id="error" style="color: #ff0c05;"></span>
		            </form>
		        </div>
		
		        <!--<div class="pad-all">-->
		        <!--</div>-->
		    </div>
		</div>
	</div>
<script>
	$(function () {
		$('#sub').click(function () {
            login();
        });
        $('#username, #password, #captcha').keyup(function(event){
            if(event.keyCode ==13){
                login();
            }
        });
    })
</script>
	<script>
		function login() {
            var data = $('form').serialize();
            var index = layer.load(1);
            $.ajax({
                type: "POST",
                url: "{:url('admin/auth/login')}",
                data: data,
                //返回数据的格式
                datatype: "json",
                //成功返回之后调用的函数
                success: function (data) {
                    layer.close(index);
                    if (data.status == 1) {
//                        layer.msg('登录', {icon: 1, time: 600}, function () {
                        window.location.href = "{:url('admin/index/index')}";
//                        })
                    } else {
                        $('#captcha_img').click();
                        $('#error').html(data.msg)
                    }
                },
                //调用出错执行的函数
                error: function () {
                    layer.close(index);
                    layer.alert('系统异常')
                    //请求出错处理
                }
            });
        }
	</script>
	<script src="__admin__/js/layer/layer.js"></script>
</body>
</html>
